package com.tencet.servlet;

import com.alibaba.druid.support.json.JSONUtils;
import com.tencet.dao.impl.WithdrawalDAOImpl;
import com.tencet.entity.AccountOne;
import com.tencet.service.AccountOneService;
import com.tencet.service.AccountTwoService;
import com.tencet.service.Impl.AccountOneServiceImpl;
import com.tencet.service.Impl.AccountTwoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: @date: 2022/7/21 19:33
 * @description:
 */
@WebServlet("/withdrawal2")
public class WithdrawalServlet2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String card2_num = (String)req.getSession().getAttribute("card2_num");

        AccountTwoService accountTwoService = new AccountTwoServiceImpl();
        String id = accountTwoService.getId(card2_num);
        AccountOneService accountOneService = new AccountOneServiceImpl();
        java.util.List<AccountOne> list = accountOneService.getAccountOneList(id);
        List<String > card_num = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            card_num.add(list.get(i).getCard_num());
        }
//        List card_num = ww.getCard_num(phone);
        String s = JSONUtils.toJSONString(card_num);
        resp.getWriter().write(""+s);
    }
}